package com.test;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * Created by 19711 on 2023/3/16.
 */
public class test {
    public static void main(String[] args) throws ClassNotFoundException, SQLException {
   Class.forName("com.mysql.jdbc.Driver");
       String url ="jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true";
       String user="root";
       String pwd="123456";

        Connection connection=DriverManager.getConnection(url,user,pwd);
        if (connection==null){
            System.out.println("链接失败");

        }else{
            System.out.println("连接成功");
        }
       Statement statement= connection.createStatement();

        String sql="INSERT INTO bank VALUES(3,'王宝',1400)";
        if (statement.executeUpdate(sql)>= 1){
            System.out.println("插入成功");
        }else{
            System.out.println("插入失败");
        }


        connection.close();
    }
}
